package com.xx.job.controller.system;


import com.xx.job.common.Result;
import com.xx.job.controller.dto.PageDTO;
import com.xx.job.entity.system.SysUser;
import com.xx.job.service.system.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import com.xx.job.controller.base.BaseController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liangcy
 * @since 2021-01-14
 */
@RestController
@RequestMapping("/api/v1")
public class SysUserController extends BaseController {


    @Autowired
    private SysUserService sysUserService;

    @GetMapping("/sysUserList")
    public Result sysUserList(PageDTO pageDto,SysUser sysUser) {
        Map<String, Object> data = sysUserService.selectUserList(pageDto, sysUser);
        return Result.success(data);
    }

    @GetMapping("/sysUser")
    public Result sysUserParam() {
        Map<String, Object> data = sysUserService.selectUserParam();
        return Result.success(data);
    }

    @GetMapping("/sysUser/{id}")
    public Map<String, Object> sysUser(@PathVariable Long id) {
        Map<String, Object> stringObjectMap = sysUserService.selectUser(id);
        return stringObjectMap;
    }

    @PostMapping("/sysUser")
    public Result addSysUser(@RequestBody SysUser sysUser) {
        return Result.success(sysUserService.addSysUser(sysUser));
    }

    @PutMapping("/sysUser")
    public Result update(@RequestBody SysUser sysUser){
        return Result.success(sysUserService.update(sysUser));
    }

    @DeleteMapping("/sysUser/{ids}")
   public Result delete(@PathVariable List<Long> ids){
        return Result.success(sysUserService.delete(ids));
   }

    @GetMapping("/configKey/{password}")
    public Result configKey(@PathVariable String password) {
        return Result.success("123456");
    }
}

